<template>
  <!-- 第二级单元 -->
  <div class="exhibits-box" style="height: 100%" v-if="currentItem">
    <div class="child-list">
      <div
        @click="changeCurrent(index)"
        class="child-item"
        :class="{ 'item-active': current === index, 'item-mg': index === 0 }"
        v-for="(item, index) in info.children"
        :key="item.id"
      >
        <div class="child-item-left"></div>
        <div class="child-item-center">
          <span>{{ item.text }}</span>
        </div>
        <div class="child-item-right"></div>
      </div>
    </div>

    <div class="exhibits-right">
      <div class="exhibits-right-heard">
        <img
          v-if="info.children[current].value"
          class="banner-img t-image--fit-cover t-image--position-center"
          :src="$filters.getLinkUrl(info.children[current].value + '?imageView2/0/h/200/format/webp')"
          alt=""
          :style="{ marginTop: info.children.length <= 1 ? '16px' : '0px' }"
        />
        <!-- <span v-if="currentItem?.remarks">{{ currentItem?.remarks }}</span> -->
        <!-- <readMore :id="currentItem.id" :remarks="currentItem.remarks" :flag="false"></readMore> -->
      </div>
    </div>
    <!-- 第三级单元 -->
    <!-- <pageChild2Vue :current="current" v-if="currentItem.children.length > 0" /> -->

    <!-- 是否有展品 -->

    <pageChildItem3 :id="info.children[current].id" v-if="currentItem.children.length === 0" />
  </div>
</template>
<script lang="ts">
import { defineComponent, onActivated, onDeactivated } from 'vue';
export default defineComponent({
  name: 'pageChildItem1',
});
</script>
<script setup lang="ts">
// @ts-nocheck
import { ref, computed, watch, reactive } from 'vue';
import { useRouter, useRoute } from 'vue-router';
import { MessagePlugin } from 'tdesign-vue-next';
import { useProjectStore } from '@/store';
import { storeToRefs } from 'pinia';
import dotIcon from './dotIcon.vue';
import readMore from '../wapComponents/readMore.vue';
import arrowLeft from './arrowLeft.vue';
import arrowRight from './arrowRight.vue';
import pageChild1Vue from './pageChild1.vue';
import pageChildItem3 from './pageChildItem3.vue';
const store = useProjectStore();
const { childModel, styleInfo, current } = storeToRefs(store);
const router = useRouter();
const route = useRoute();
// const current = ref(0);
// if (route.query.current) {
//   console.log(route.query.current, 'current----');

//   current.value = Number(route.query.current);
// }
const info = computed(() => store.childModel);

const currentItem = computed(() => info.value.children[current.value]);

const isCurrentFirst = computed(() => current.value === 0);

const isCurrentLast = computed(() => current.value === info.value.children.length - 1);

const changeCurrent = (index) => {
  current.value = index;
};

const setCurrent = (index) => {
  current.value = index;
};

watch(
  () => route.query.current,
  (value) => {},
  { deep: true },
);

onActivated(() => {
  // console.log('是否触发onActivated');
});
</script>

<style lang="less" scoped>
.title-box {
  font-size: 17px;
  // font-family: SourceHanSerif;
  font-weight: 500;
  color: #333333;
  line-height: 32px;
  margin-top: 50px;
}
.exhibits-box {
  // display: flex;
  width: 100%;

  // height: 930px;
  padding-top: 20px;
}
.exhibits-left {
  padding: 8px 21px;
  width: 256px;
  height: 600px;
  overflow-y: auto;
  color: #333333;
}
.item-box {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  // line-height: 30px;

  font-family: SourceHanSerifCN-Bold, SourceHanSerifCN;
  // width: 100%;
  padding: 0 8px;
  // height: 64px;
  // overflow: hidden;
  // white-space: nowrap;
  // text-overflow: ellipsis;
  > span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}
.exhibits-right-heard {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
  // margin-bottom: 50px;
  position: relative;
  text-indent: 2em;
  padding: 0 16px;
  padding-bottom: 16px;
  img {
    width: 100%;
    // height: 480px;
  }
  span {
    width: 100%;
    font-weight: 500;
    color: #333333;
    line-height: 32px;
    text-indent: 2em;
    text-align: justify;
    padding-top: 10px;
  }
  :deep(.remarks-text) {
    color: #666;
  }
}
.exhibits-right {
  width: 100%;
  display: flex;
  flex-direction: column;
  // overflow: hidden;
  margin: auto;
  // padding: 0 21px;
  flex: 1;
  position: relative;
  // margin-top: 130px;
}
.t-row {
  margin: 0;
}
.exhibits-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  cursor: pointer;
  img {
    height: 280px;
    background: #f0e9e1;
    // width: 100%;
    // height: 210px;
  }
}
.item-title {
  width: 100%;
  padding: 24px;

  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  span {
    font-size: 18px;
    // font-family: SourceHanSerifCN-Medium, SourceHanSerifCN;
    font-weight: 400;
    color: #333333;
    line-height: 28px;
  }
}
.exhibits-content {
  width: 100%;
  margin: auto;
  // margin-top: 50px;
  padding-bottom: 80px;
  background: #f0e9e1;
}
.scroll-x-box {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
  height: 40px;
  overflow: hidden;
  overflow-x: auto;
  box-shadow: inset 0px -1px 0px 0px rgba(230, 230, 230, 0.5);
}
.scroll-x-box-item {
  display: flex;
  justify-content: center;
  cursor: pointer;
  border: none;
  text-align: center;
  padding: 8px 0;
  // width: 100px;
  margin: 0 40px;
  span {
    display: flex;
    justify-content: center;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: center;
  }
}
.scroll-x-box-item-active {
  border-bottom: 1px solid transparent;
}
.is-null-box {
  width: 100%;
  display: flex;
  justify-content: center;
  margin: 50px 0;
  span {
    font-size: 24px;
    // font-family: SourceHanSerif;
    font-weight: bold;
    color: rgba(0, 0, 0, 0.9);
    line-height: 22px;
  }
}
.exhibits-righ-dot {
  display: flex;
  justify-content: center;
  align-items: center;
}

.currentItemText {
  position: absolute;
  top: 0;
}
.iconbox-parent {
  position: relative;
  display: flex;
  align-items: center;
  .currentItemText {
    left: 0;
    width: 100%;
    text-align: center;
    color: #fff;
  }
}

.iconbox {
  width: 100%;
  height: 100%;
  .iconfonts {
    font-size: 32px;
  }
}
.banner-img {
  width: 100% !important;
  height: 200px;
  // height: 480px !important;
}
.subTitle {
  text-align: center;
  color: rgba(51, 51, 51, 0.6);
  padding: 0 16px;
  font-size: 15px;
  margin-top: 6px;
}
.remarks-box {
  margin-top: 10px;
}

.child-list {
  display: flex;
  width: 100%;
  padding: 0 16px;
  margin-top: 6px;
  justify-content: center;
}
.child-item {
  display: flex;
  align-items: center;
  margin-left: 24px;
}

.item-mg {
  margin-left: 0;
}
.child-item-left,
.child-item-right {
  width: 3px;
  height: 29px;
  border: 1px solid #a2463c;
}
.child-item-center {
  display: flex;
  align-items: center;
  border-top: 1px solid #a2463c;
  border-bottom: 1px solid #a2463c;
  height: 25px;
  font-family: 'SourceHanSerifCN-Medium';
  font-size: 14px;
  color: #a2463c;
  line-height: 25px;
  padding: 0 8px;
}
.item-active {
  .child-item-left,
  .child-item-right {
    background: #a2463c;
  }
  .child-item-center {
    background: #a2463c;
    color: #ffffff;
  }
}
</style>
